SYSMENU.DLL -- Author: Jeff Simms -- CIS 72200,3173 -- August 7, 1992 Freeware DLL subclasses VB form and waits on WM_SYSCOMMAND messages that are relayed back to the form as keypress events. Declare Sub VBSysAbout Lib "SYSMENU.DLL" (ByVal hWnd As Integer, ByVal bSwitch As Integer) Usage: Call VBSysAbout(hWnd, 1) Notes: 1) Boolean switch if not zero appends an "About..." menu item to the system menu and sends a WM_CHAR message to the form with the wParam = 256 when selected. 2) You may append as many menu items as you like to the system menu. You are responsible for keeping track of their id's. These id's will be relected back to the form_keypress event as keyascii. These id's must be less than 61440. If you have any questions/suggestions/problems/answers/whatever let me know. * Use at own risk * *** SYSMENU.C *** #include #include "sysmenu.h" FARPROC lpfnVBMainWndProc; HWND vbmain; int FAR PASCAL WEP (int bSystemExit) { return (1); } void __export FAR PASCAL VBSysAbout(HWND hWndVBMain, BOOL bSwitch) { HMENU hSysMenu; WORD r; vbmain = hWndVBMain; if (bSwitch) { hSysMenu = GetSystemMenu(vbmain, 0); r = AppendMenu(hSysMenu, MF_ENABLED, 256, "&About..."); } lpfnVBMainWndProc = (FARPROC) SetWindowLong(hWndVBMain,GWL_WNDPROC, (DWORD)(FARPROC) MyMainWndProc); } LONG __export FAR PASCAL MyMainWndProc(HWND hWnd,unsigned wMsg,WORD wParam,LONG lParam) { switch(wMsg) { case WM_SYSCOMMAND: if (wParam < 0xF000) { PostMessage(vbmain,WM_CHAR,wParam,0L); return 0; } break; case WM_DESTROY: SetWindowLong(vbmain,GWL_WNDPROC,(DWORD)lpfnVBMainWndProc); PostMessage(vbmain,WM_DESTROY,0,0L); return 0; } return(CallWindowProc(lpfnVBMainWndProc,hWnd, wMsg, wParam, lParam)); }